package A1;
import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: Ferdy
 * Date: 31 Mar 11
 * Time: 14:00:39
 * To change this template use File | Settings | File Templates.
 */
/**all details about cars*/
public class Cars {
    Grid gr=new Grid();
    Random rand=new Random();

    private int xPos = 0;
    private int yPos =0;
    private int count = 0;

    /**determine the probability of horizontal car appearance*/
    public ArrayList<Cars> setHorCar(ArrayList<Cars> hCarList,int horLane,double horCar,int count){
        double randCar;
        hCarList.add(new Cars());
        randCar=rand.nextDouble();
        if (randCar<=horCar){hCarList.get(count).setHLane(rand.nextInt(horLane)+1);}
        else hCarList.get(count).setHLane(0);
        System.out.println(gr.hCarList.size());
        return hCarList;
    }

    /**determine the probability of vertical car appearance*/
    public ArrayList<Cars> setVerCar(ArrayList<Cars> vCarList, int verLane,double verCar,int count){
        double randCar;
        vCarList.add(new Cars());
        randCar=rand.nextDouble();
        if (randCar<=verCar){vCarList.get(count).setVLane(rand.nextInt(verLane)+1);}
        else vCarList.get(count).setVLane(0);
        return vCarList;
    }


    /**set the horizontal lane to class cars*/
    public void setHLane(int lane){xPos=lane;}
    /**get the horizontal lane to class cars*/
    public int getHLane() {return xPos;}

    /**set the vertical lane to class cars*/
    public void setVLane(int lane){yPos=lane;}
    /**get the vertical lane to class cars*/
    public int getVLane() {return yPos;}

    /**set the number of car step*/
    public void setCount(int run) {count = count + run;}
    /**get the number of car step*/
    public int getCount() {return count;}






}